// 轻量日志工具：默认屏蔽非关键日志，仅在开发模式并显式开启时输出
// 在控制台执行 window.__APP_DEBUG__ = true 可临时开启调试输出

const isDev = typeof import.meta !== 'undefined' && import.meta.env && import.meta.env.DEV

function shouldDebug() {
  // 仅在开发环境且手动开启时允许 debug/info 输出
  return isDev && typeof window !== 'undefined' && (window as any).__APP_DEBUG__ === true
}

export const logger = {
  debug: (...args: any[]) => {
    if (shouldDebug()) console.debug(...args)
  },
  info: (...args: any[]) => {
    if (shouldDebug()) console.info(...args)
  },
  warn: (...args: any[]) => console.warn(...args),
  error: (...args: any[]) => console.error(...args)
}

export default logger
